<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :dictMap="dictMapAsync"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :defaultEventKey="defaultEventKey"
      :labelWidth="75"
    ></Ht-search-form>

    <ht-table
      ref="dataTable"
      :multi-select="false"
      :showSerialNumber="false"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      :reqConfig="regConfig"
      :defaultEventKey="defaultEventKey"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="50" fixed="right">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog
      :title="title"
      center
      :visible.sync="open"
      width="1024px"
      append-to-body
      :close-on-click-modal="false"
      v-if="open"
    >
      <el-form ref="detailForm" :model="detailForm" :rules="rules" label-width="180px">
        <el-card class="form-card msgGroup-card">
          <div slot="header" class="label-header-msg">
            <span>原交易明细信息</span>
          </div>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="交易流水号" prop="oriID">
              <el-input v-model="detailForm.oriID" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="报文标识号" prop="pkgId">
              <el-input v-model="detailForm.pkgId" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="发起参与机构" prop="directSender">
              <el-input v-model="detailForm.directSender" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="发起参与机构名" prop="directSenderName">
              <el-input v-model="detailForm.directSenderName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="接收参与机构" prop="directRecver">
              <el-input v-model="detailForm.directRecver" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="接收参与机构名" prop="directRecverName">
              <el-input v-model="detailForm.directRecverName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="备注" prop="remarks">
              <el-input type="textarea" v-model="detailForm.remarks" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="费用标识" prop="feeId">
              <el-select style="width: 100%" v-model="detailForm.feeId" placeholder="费用标识" :disabled="true">
                <el-option
                  v-for="dict in dictMap.FEE_ID"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="统一社会信用代码" prop="uniformScCode">
              <el-input v-model="detailForm.uniformScCode" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="客户标识" prop="custId">
              <el-input type="textarea" v-model="detailForm.custId" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="客户标识类型" prop="custType">
              <el-select style="width: 100%" v-model="detailForm.custType" placeholder="客户标识类型" :disabled="true">
                <el-option
                  v-for="dict in dictMap.Cust_Identy_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="特约委收种类代码" prop="spTypeCode">
              <el-input v-model="detailForm.spTypeCode" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="缴款日期" prop="tradeDate">
              <el-date-picker
                v-model="detailForm.tradeDate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
                :disabled="true"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="缴费类型" prop="payType">
              <el-select style="width: 100%" v-model="detailForm.payType" placeholder="缴费类型" :disabled="true">
                <el-option
                  v-for="dict in dictMap.Pmt_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="缴款渠道" prop="paymentType">
              <el-select style="width: 100%" v-model="detailForm.paymentType" placeholder="缴款渠道" :disabled="true">
                <el-option
                  v-for="dict in dictMap.Pay_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="收款人账户类型" prop="payeeAccType">
              <el-input v-model="detailForm.payeeAccType" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="收款清算行" prop="institutePayeeStBrno">
              <el-input v-model="detailForm.institutePayeeStBrno" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="附加号码内容" prop="addNumContent">
              <el-input type="textarea" v-model="detailForm.addNumContent" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="票据业务类型" prop="billType">
              <el-input v-model="detailForm.billType" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="票据校验码" prop="billChkCode">
              <el-input v-model="detailForm.billChkCode" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="网点编码" prop="branchCode">
              <el-input v-model="detailForm.branchCode" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="代收付中心" prop="institutionId">
              <el-input v-model="detailForm.institutionId" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="付款人名称" prop="payerName">
              <el-input v-model="detailForm.payerName" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="证件类型" prop="idType">
              <el-select style="width: 100%" v-model="detailForm.idType" placeholder="证件类型" :disabled="true">
                <el-option
                  v-for="dict in dictMap.Id_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="证件号码" prop="idNum">
              <el-input v-model="detailForm.idNum" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="原报文标识号" prop="oriPkgId">
              <el-input v-model="detailForm.oriPkgId" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="原发起参与机构" prop="oriSender">
              <el-input v-model="detailForm.oriSender" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="原报文类型" prop="oriMsgType">
              <el-input v-model="detailForm.oriMsgType" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="付款人账号" prop="payerActno">
              <el-input v-model="detailForm.payerActno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="付款人开户行行号" prop="payerAccBrno">
              <el-input v-model="detailForm.payerAccBrno" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="收款人名称" prop="payeeName">
              <el-input type="textarea" v-model="detailForm.payeeName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="收款行行号" prop="payeeBrno">
              <el-input v-model="detailForm.payeeBrno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="收款人账号" prop="payeeActno">
              <el-input v-model="detailForm.payeeActno" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="收款人开户行行号" prop="payeeAccBrno">
              <el-input v-model="detailForm.payeeAccBrno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="付款清算行行号" prop="payerStBrno">
              <el-input v-model="detailForm.payerStBrno" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="付款行行号" prop="payerBrno">
              <el-input v-model="detailForm.payerBrno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="收款清算行行号" prop="payeeStBrno">
              <el-input v-model="detailForm.payeeStBrno" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="业务类型编码" prop="bizTypeCode">
              <el-select
                style="width: 100%"
                v-model="detailForm.bizTypeCode"
                placeholder="业务类型编码"
                :disabled="true"
              >
                <el-option
                  v-for="dict in dictMap.BIZ_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="业务种类编码" prop="bizCtgyCode">
              <el-select
                style="width: 100%"
                v-model="detailForm.bizCtgyCode"
                placeholder="业务种类编码"
                :disabled="true"
              >
                <el-option
                  v-for="dict in dictMap.BIZ_CTGY_BEPS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="缴款总金额币种" prop="totalCurcd">
              <el-input v-model="detailForm.totalCurcd" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="缴款总金额" prop="totalAmt">
              <ht-amount-input v-model="detailForm.totalAmt" placeholder="缴款总金额" :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="需付款行代扣的手续费币种" prop="feeCurcd">
              <el-input v-model="detailForm.feeCurcd" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="需付款行代扣的手续费" prop="feeAmt">
              <ht-amount-input
                v-model="detailForm.feeAmt"
                placeholder="需付款行代扣的手续费"
                :disable="true"
              ></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="备注1" prop="remarks1">
              <el-input type="textarea" v-model="detailForm.remarks1" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="备注2" prop="remarks2">
              <el-input type="textarea" v-model="detailForm.remarks2" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="经办人" prop="operator">
              <el-input type="textarea" v-model="detailForm.operator" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="明细条数" prop="dtlNum">
              <el-input v-model="detailForm.dtlNum" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="资金到账情况" prop="fundRcvStatus">
              <el-input v-model="detailForm.fundRcvStatus" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>
          <div class="discountReceipt-pick-operate-box">
            <div class="operate-box-bottom">
              <div class="bottom-content">
                <ht-table
                  ref="dataTableDetail"
                  :multi-select="false"
                  :showSerialNumber="false"
                  :dictMap="dictMap"
                  :queryParams="queryParamsDetail"
                  :tableBindColumns="tableBindColumnsDetail"
                  :opButtonList="opButtonList"
                  :reqConfig="regConfigDetail"
                  :showRightToolbar="false"
                />
              </div>
            </div>
          </div>
        </el-card>
        <el-card class="list-card msgGroup-user">
          <div slot="header" class="label-header-msg">
            <span>应答交易明细信息</span>
          </div>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="业务状态" prop="bizStatus">
              <el-select style="width: 100%" v-model="detailForm.bizStatus" placeholder="业务状态">
                <el-option
                  v-for="dict in dictMap.PROCESSSTATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="业务拒绝处理码" prop="bizRejectCode">
              <el-select
                style="width: 100%"
                v-model="detailForm.bizRejectCode"
                placeholder="业务拒绝处理码"
                :disabled="isPR05"
              >
                <el-option
                  v-for="dict in dictMap.CIS_CODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="业务拒绝信息" prop="bizRejectInfo">
              <el-input type="textarea" v-model="detailForm.bizRejectInfo" :disabled="isPR05" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="业务处理参与机构" prop="bizProOrg">
              <el-input v-model="detailForm.bizProOrg" @change="checkbankcode('bizProOrg')" />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label-width="20px">
              <el-button icon="el-icon-search" plain type="primary" @click="openBankBranchDialog('bizProOrg')">
                请选择
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="业务处理参与机构名" prop="bizProOrgName">
              <el-input v-model="detailForm.bizProOrgName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="原结算金额币种" prop="orgSettleCurcd">
              <el-input v-model="detailForm.orgSettleCurcd" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="原结算金额" prop="orgSettleAmt">
              <ht-amount-input v-model="detailForm.orgSettleAmt" placeholder="原结算金额"></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="入账通知编号" prop="crdNo">
              <el-input v-model="detailForm.crdNo" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="动账标识" prop="accChgFlg">
              <el-select style="width: 100%" v-model="detailForm.accChgFlg" placeholder="动账标识">
                <el-option
                  v-for="dict in dictMap.Acc_Chg_Flg_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="地域标识" prop="regionId">
              <el-input v-model="detailForm.regionId" @change="getbase('RegionId')" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-input v-model="detailForm.regionIdDesc" :disabled="true" />
          </el-col>

          <el-col :span="6">
            <el-form-item label-width="20px">
              <el-button icon="el-icon-search" plain type="primary" @click="openBasedataDialog('RegionId')">
                请选择
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="附言" prop="addInfo">
              <el-input type="textarea" v-model="detailForm.addInfo" maxlength="256" show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="save" v-loading.fullscreen.lock="loading">提 交</el-button>
        <el-button type="primary" @click="refresh">重 置</el-button>
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>

      <bank-branch-dialog ref="bankBranchDialog" @confirm="confirmBankBranch"></bank-branch-dialog>
      <base-data-dialog ref="basedataDialog" @confirm="confirmData"></base-data-dialog>
    </el-dialog>
  </div>
</template>

<script>
import { listPageMixin } from "@/libs/listPageMixin";

import { amountThousandsFormatter } from "@/utils/table_col_formatter";
import HtAmountInput from "@/views/components/HtAmountInput";
import {
  realTimePaymentResponseEntryDetail,
  realTimePaymentResponseEntryDetailTableQuery,
  realTimePaymentResponseEntryQuery,
  realTimePaymentResponseEntrySave,
} from "@/api/cnaps/beps/364";
import BankBranchDialog from "@/views/components/BankBranchDialog";
import { getBankInfByBankCode } from "@/api/cnaps/common/bankInfo";
import BaseDataDialog from "@/views/components/BasedataDialog";
import { getBasedata } from "@/api/cnaps/common/basedata";

export default {
  name: "RealTimePaymentResponseEntry",
  mixins: [listPageMixin],
  components: { BaseDataDialog, BankBranchDialog, HtAmountInput },
  data() {
    return {
      // 查询参数
      queryParams: {
        idSeqno: undefined,
        pkgId: undefined,
        startcpgdate: undefined,
        endcpgdate: undefined,
        startworkdate: undefined,
        endworkdate: undefined,
      },
      queryParamsDetail: {
        oriID: undefined,
      },
      loading: false,
      // 搜索
      defaultEventKey: "defaultEventKey",
      formOptions: [],
      //
      searchFormDictList: [
        "PKG_STATUS",
        "Cust_Identy_Type_Code",
        "Pmt_Type_Code",
        "Pay_Code",
        "Id_Type_Code",
        "Acc_Chg_Flg_Code",
        "PROCESSSTATUS",
        "CIS_CODE",
        "BIZ_TYPE",
        "BIZ_CTGY_BEPS",
      ],
      // 列信息
      regConfig: realTimePaymentResponseEntryQuery,

      regConfigDetail: realTimePaymentResponseEntryDetailTableQuery,

      tableBindColumns: [
        { prop: "id", label: "流水号", width: 180 },
        { prop: "cpgdate", label: "CPG日期", type: "date" },
        { prop: "workdate", label: "工作日期", type: "date" },
        { prop: "pkgId", label: "报文标识号", width: 180 },
        { prop: "feeId", label: "费用标识", width: 180 },
        { prop: "uniformScCode", label: "统一社会信用代码", width: 180 },
        { prop: "status", label: "状态", dictCode: "PKG_STATUS" },
      ],

      tableBindColumnsDetail: [
        { prop: "billCode", label: "账单编号", width: 120 },
        { prop: "payCurcd", label: "缴款金额币种", width: 120 },
        { prop: "payAmt", label: "缴款金额", type: "price", width: 120 },
        { prop: "billCurcd", label: "账单金额币种", width: 120 },
        { prop: "billAmt", label: "账单金额", type: "price", width: 120 },
        { prop: "otFeeCurcd", label: "其他扣费币种", width: 120 },
        { prop: "otFee", label: "其他扣费", type: "price", width: 120 },
        { prop: "serviceCurcd", label: "手续费币种", width: 120 },
        { prop: "serviceAmt", label: "手续费", type: "price", width: 120 },
        { prop: "billDate", label: "账期区间", width: 120 },
        { prop: "paymentInfo", label: "缴费内容", width: 120 },
        { prop: "remarks", label: "备注", width: 120 },
      ],

      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      detailForm: {
        bizStatus: undefined,
        bizRejectCode: undefined,
        bizRejectInfo: undefined,
        bizProOrg: undefined,
        bizProOrgName: undefined,
        orgSettleCurcd: "CNY",
        orgSettleAmt: 0,
        crdNo: undefined,
        accChgFlg: undefined,
        regionId: undefined,
        regionIdDesc: undefined,
        addInfo: undefined,
      },
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,
      isPR05: false,
      rules: {
        id: [{ max: 20, message: "长度最大为20位", trigger: "blur" }],
        bizRejectInfo: [{ max: 315, message: "长度最大为315位", trigger: "blur" }],
        bizProOrg: [{ max: 14, message: "长度最大为14位", trigger: "blur" }],
        orgSettleCurcd: [
          { required: true, message: "原结算金额币种不能为空", trigger: "blur" },
          { max: 3, message: "长度最大为3位", trigger: "blur" },
        ],
        orgSettleAmt: [{ required: true, message: "原结算金额不能为空", trigger: "blur" }],
        crdNo: [{ max: 30, message: "长度最大为30位", trigger: "blur" }],
        regionId: [{ required: true, message: "地域标识不能为空", trigger: "blur" }],
        addInfo: [{ max: 768, message: "长度最大为768位", trigger: "blur" }],
        bizRejectCode: [{ required: false, message: "业务拒绝处理码不能为空", trigger: "blur" }],
      },
    };
  },
  watch: {
    "detailForm.bizStatus": {
      handler(val) {
        this.isPR05 = false;
        this.$set(this.rules.bizRejectCode[0], "required", false);

        if (val === "PR09") {
          this.$set(this.rules.bizRejectCode[0], "required", true);
        }
        if (val === "PR05") {
          this.isPR05 = true;
          this.$set(this.detailForm, "bizRejectCode", "");
          this.$set(this.detailForm, "bizRejectInfo", "");
        }
      },
    },
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "idSeqno",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },

      {
        type: "input",
        prop: "pkgId",
        defaultAttr: {
          size: "small",
          label: "报文标识号",
          placeholder: "请输入报文标识号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "startcpgdate",
          endTimeName: "endcpgdate",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG日期开始", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "startworkdate",
          endTimeName: "endworkdate",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作日期开始", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    //点击重置按钮
    refresh() {
      this.detailForm.regionIdDesc = "";
      this.resetForm("detailForm");
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "实时缴款业务应答报文录入明细";
      realTimePaymentResponseEntryDetail(row).then((response) => {
        this.detailForm = response.result;
        this.queryParamsDetail.oriID = response.result.id;
        this.$set(this.detailForm, "oriID", response.result.id);
        this.$set(this.detailForm, "bizStatus", "");
        this.$set(this.detailForm, "bizRejectCode", "");
        this.$set(this.detailForm, "bizRejectInfo", "");
        this.$set(this.detailForm, "bizProOrg", "");
        this.$set(this.detailForm, "bizProOrgName", "");
        this.$set(this.detailForm, "orgSettleCurcd", "CNY");
        this.$set(this.detailForm, "orgSettleAmt", 0);
        this.$set(this.detailForm, "crdNo", "");
        this.$set(this.detailForm, "accChgFlg", "");
        this.$set(this.detailForm, "regionId", "");
        this.$set(this.detailForm, "regionIdDesc", "");
        this.$set(this.detailForm, "addInfo", "");
        this.open = true;
      });
    },
    //点击提交按钮
    save: function () {
      this.$refs["detailForm"].validate((valid) => {
        if (valid) {
          realTimePaymentResponseEntrySave(this.detailForm)
            .then((res) => {
              this.loading = true;
              this.msgSuccess("提交成功");
              this.open = false;
              this.loading = false;
              this.$alert(`CORE_ID: ${res.result.rspId}`, "生成交易流水号", {
                confirmButtonText: "确定",
                callback: (action) => {
                },
              });
              this.$nextTick(() => {
                this.$refs.dataTable.doQuery(true);
              });
            })
            .catch((err) => {
              this.loading = false;
            });
        }
      });
    },

    //行名行号返回
    confirmBankBranch(fromFlag, row) {
      if (fromFlag === "bizProOrg") {
        this.$set(this.detailForm, "bizProOrg", row.bankCode);
        this.$set(this.detailForm, "bizProOrgName", row.orgFullname);
      }
    },
    //行名行号查询
    openBankBranchDialog(fromFlag = "") {
      this.$refs.bankBranchDialog.show(fromFlag);
    },

    checkbankcode(fromFlag) {
      if (fromFlag === "bizProOrg") {
        let bizProOrg = this.detailForm.bizProOrg;
        getBankInfByBankCode(bizProOrg)
          .then((response) => {
            if (response.code == "S" && response.result !== null && response.result !== undefined) {
              this.$set(this.detailForm, "bizProOrg", response.result.bankCode);
              this.$set(this.detailForm, "bizProOrgName", response.result.orgFullname);
            } else {
              this.msgError("无行名行号记录");
              this.$set(this.detailForm, "bizProOrg", null);
              this.$set(this.detailForm, "bizProOrgName", null);
            }
          })
          .catch((err) => {
            this.$set(this.detailForm, "bizProOrg", null);
            this.$set(this.detailForm, "bizProOrgName", null);
          });
      }
    },

    openBasedataDialog(dataType = "") {
      this.$refs.basedataDialog.show(dataType);
    },

    confirmData(fromFlag, row) {
      this.$set(this.detailForm, "regionId", row.dataValue);
      this.$set(this.detailForm, "regionIdDesc", row.dataDesc);
    },

    //回车获取basedata值
    getbase(dataType) {
      const dataValue = this.detailForm.regionId;
      if (dataValue === "" || dataValue === null || dataValue === undefined) {
        return;
      }

      getBasedata(dataType, dataValue)
        .then((response) => {
          if (response.code == "S" && response.result !== null && response.result !== undefined) {
            this.$set(this.detailForm, "regionId", response.result.dataValue);
            this.$set(this.detailForm, "regionIdDesc", response.result.dataDesc);
          } else {
            this.msgSuccess("找不到对应的字典项");
            this.$set(this.detailForm, "regionId", null);
            this.$set(this.detailForm, "regionIdDesc", null);
          }
        })
        .catch((err) => {
          this.$set(this.detailForm, "regionId", null);
          this.$set(this.detailForm, "regionIdDesc", null);
        });
    },
  },
};
</script>
